package com.itheima.day02;

import com.itheima.day01.Chat;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;

public class MyService {
    public static void main(String[] args) throws IOException {
        System.out.println("-----Server-----");
        // 1、指定端口 使用ServerSocket创建服务器
        ServerSocket server = new ServerSocket(8888);

        // 2、阻塞式等待连接 accept将本地的类字节码传输给客户端
        byte[] data = new byte[10000];
        FileInputStream fis = new FileInputStream("C:\\Sort.class");
        int length = fis.read(data);

        PrintStream ps = new PrintStream(server.getOutputStream());
        ps.write(data,0,length);
    }
}
